{include file="header.html"}
<script src="/js/ckeditor/ckeditor.js"></script>
<div class="page-header">
	<h6>
		商品管理
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			商品添加
		</small>
	</h6>
</div>
<div class="row">
<div class="col-xs-12">
	<form class="form-horizontal" role="form" method="post" action="?app=goods&act=add" enctype="multipart/form-data">
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="name"> 名称 </label>
			<div class="col-sm-10">
				<input type="text" id="name" name="name" value="" class="col-xs-6" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="pic"> 主图片 </label>
			<div class="col-sm-10">
				<div class="col-file col-xs-3"><input type="file" id="pic" name="pic" value="" /></div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="description"> 简要描述 </label>
			<div class="col-sm-10">
				<input type="text" id="description" name="description" value="" class="col-xs-6" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="keywords"> 关键词 </label>
			<div class="col-sm-10">
				<input type="text" id="keywords" name="keywords" value="" class="col-xs-6 some-width" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="weight"> 重量 </label>
			<div class="col-sm-10">
				<input type="text" id="weight" name="weight" value="" class="col-xs-6 some-width" /><span class="some-line"> kg </span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="size"> 体积 </label>
			<div class="col-sm-10">
				<input type="text" id="size" name="size" value="" class="col-xs-6 some-width" /><span class="some-line"> cm<sup>3</sup> </span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="price"> 价格 </label>
			<div class="col-sm-10">
				<input type="text" id="price" name="price" value="" class="col-xs-6 some-width" /><span class="some-line"> 元 （默认规格）</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="market_price"> 市场价格 </label>
			<div class="col-sm-10">
				<input type="text" id="market_price" name="market_price" value="" class="col-xs-6 some-width" /><span class="some-line"> 元 </span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="cost_price"> 成本价 </label>
			<div class="col-sm-10">
				<input type="text" id="cost_price" name="cost_price" value="" class="col-xs-6 some-width" /><span class="some-line"> 元 </span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="promote_price"> 促销价、特价 </label>
			<div class="col-sm-10">
				<input type="text" id="promote_price" name="promote_price" value="" class="col-xs-6 some-width" /><span class="some-line"> 元 （默认规格）</span>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="begin_time"> 促销开始日期 </label>
			<div class="col-sm-10">
				<input type="text" id="begin_time" name="begin_time" value="" class="col-xs-6 some-width" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="end_time"> 促销结束日期 </label>
			<div class="col-sm-10">
				<input type="text" id="end_time" name="end_time" value="" class="col-xs-6 some-width" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="cate"> 所属分类 </label>
			<div class="col-sm-2">
				<select name="cate" id="cate" class="form-control some-width">
					<option value="">请选所属分类</option>
					{$categorys}
				</select>
			</div>
		</div>
		<!--
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="shop"> 所属商店 </label>
			<div class="col-sm-2">
				<select name="shop" id="shop" class="form-control some-width">
					<option value="">请选所属商店</option>
						{foreach from = $shop item =row}
						<option value="{$row->id}">{$row->name}</option>
						{/foreach}
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="brand"> 所属品牌 </label>
			<div class="col-sm-2">
				<select name="brand" id="brand" class="form-control some-width">
					<option value="">请选所属品牌</option>

					{foreach from = $brand item =row}
						<option value="{$row->id}">{$row->name}</option>
					{/foreach}

				</select>
			</div>
		</div>
		-->
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="stocks"> 库存 </label>
			<div class="col-sm-10">
				<input type="number" id="stocks" name="stocks" value="" class="col-xs-6 some-width" /><span class="some-line"> 默认规格 </span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="stocks_dg"> 库存报警数量 </label>
			<div class="col-sm-10">
				<input type="number" id="stocks_dg" name="stocks_dg" value="" class="col-xs-6 some-width" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="free"> 是否包邮 </label>
			<div class="col-sm-10">
				<div class="radio">
					<label id="free1">
						<input type="radio" name="free" value="1"  class="ace" />
						<span class="lbl"> 是</span>
					</label>
				</div>
				<div class="radio">
					<label id="free2">
						<input type="radio" name="free" value="0"  class="ace"  checked/>
						<span class="lbl"> 否</span>
					</label>
				</div>
			</div>
		</div>
		<div class="form-group cost">
			<label class="col-sm-2 control-label no-padding-right" for="fee"> 运费 </label>
			<div class="col-sm-10">
				<input type="text" id="fee" name="fee" value="" class="col-xs-6 some-width" /><span class="some-line"> 元 </span>
			</div>
		</div>
		<!--
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="integral"> 积分购买 </label>
			<div class="col-sm-10">
				<input type="text" name="integral" id="integral" value="" class="col-xs-2 some-width" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="give_integral"> 购买后赠送积分 </label>
			<div class="col-sm-10">
				<input type="text" name="give_integral" id="give_integral" value="" class="col-xs-2 some-width" />
			</div>
		</div>
		-->
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="purchase_count"> 抢购总数量 </label>
			<div class="col-sm-10">
				<input type="text" name="purchase_count" id="purchase_count" value="" class="col-xs-2 some-width" /><span class="some-line"> 为0即不参与抢购活动 </span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="ext_property"> 扩展属性 </label>
			<div class="col-sm-10">
				<div class="checkbox">
					<label id="ext_property1">
						<input type="checkbox" name="ext_property[]" id="ext_property1" value="1" class="ace"  />
						<span class="lbl"> 推荐</span>
					</label>
				</div>
				<div class="checkbox" >
					<label id="ext_property2">
						<input type="checkbox" name="ext_property[]" id="ext_property2" value="2" class="ace"  />
						<span class="lbl"> 热销</span>
					</label>
				</div>
				<!--<div class="checkbox">
					<label id="ext_property3">
						<input type="checkbox" name="ext_property[]" id="ext_property3" value="3" class="ace"  />
						<span class="lbl"> 精品</span>
					</label>
				</div>-->
				<div class="checkbox">
					<label id="ext_property4">
						<input type="checkbox" name="ext_property[]" id="ext_property4" value="4" class="ace"  />
						<span class="lbl"> 新品</span>
					</label>
				</div>
				<div class="checkbox">
					<label id="ext_property5">
						<input type="checkbox" name="ext_property[]" id="ext_property5" value="5" class="ace"  />
						<span class="lbl"> 折扣</span>
					</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="sort"> 排序 </label>
			<div class="col-sm-10">
				<input type="text" name="sort" id="sort" value="999" class="col-xs-2 some-width" />
				<span class="some-line">数字越小，排在越前</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="status"> 状态 </label>
			<div class="col-sm-10">
				<div class="radio">
					<label>
						<input type="radio" name="status" value="1" checked class="ace checked" />
						<span class="lbl"> 正常</span>
					</label>
				</div>
				<div class="radio">
					<label>
						<input type="radio" name="status" value="0" class="ace checked" />
						<span class="lbl"> 下架</span>
					</label>
				</div>
			</div>
		</div>
		<!--
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="in_shop"> 线下门店是否有销售 </label>
			<div class="col-sm-10">
				<div class="radio">
					<label>
						<input type="radio" name="in_shop" value="1" checked class="ace" />
						<span class="lbl"> 是</span>
					</label>
				</div>
				<div class="radio">
					<label>
						<input type="radio" name="in_shop" value="0" class="ace" />
						<span class="lbl"> 否</span>
					</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="sale_method"> 销售模式 </label>
			<div class="col-sm-10">
				<div class="radio">
					<label>
						<input type="radio" name="sale_method" value="1" checked class="ace" />
						<span class="lbl"> 保税直发</span>
					</label>
				</div>
				<div class="radio">
					<label>
						<input type="radio" name="sale_method" value="0" class="ace" />
						<span class="lbl"> 海外直采</span>
					</label>
				</div>
			</div>
		</div>
		-->
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="note"> 商家备注 </label>
			<div class="col-sm-10">
				<input type="text" name="note" id="note" value="" class="col-xs-2 some-width" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="content"> 详情 </label>
			<div class="col-sm-10">
				<textarea class="ckeditor" name="content" id="content" style="width:95%" rows="50"></textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label no-padding-right" for="files"> 上传相册 </label>
			<div class="col-sm-10">
				<div class="col-file col-xs-3" id="file"><input type="file" id="files" /></div>
				<div id="imgs"></div>
			</div>
		</div>
		<div class="form-group" >
			<label class="col-sm-2 control-label no-padding-right" for="spec"><span class="btn-info btn-add" id="add">+</span> 规格 </label>
			<div class="col-sm-10">
				<table id="simple-table" class="col-table">
					<thead>
						<tr>
							<th>名称：</th>
							<th>库存：</th>
							<th>价格：</th>
							<th>优惠价、特价：</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody id="addTr">
						<tr align="center">
							<td><input type="text" name="spec[]" id="spec0" value="默认规格" /></td>
							<td><input type="text" name="sto[]" id="sto0" value="" /></td>
							<td><input type="text" name="pri[]" id="pri0" value="" /></td>
							<td><input type="text" name="pro[]" id="pro0" value="" /></td>
							<td>-</td>
						</tr>
					<tbody>
				</table>
			</div>
		</div>
		
		<div class="clearfix form-actions">
			<div class="col-md-offset-3 col-md-9">
				<button class="btn btn-info" type="submit">
					<i class="ace-icon fa fa-check bigger-110"></i>
					提交
				</button>

				&nbsp; &nbsp; &nbsp;
				<button class="btn" type="reset">
					<i class="ace-icon fa fa-undo bigger-110"></i>
					重置
				</button>
			</div>
		</div>
	</form>
</div>
</div>
{include file="footer.html"}
<script>
function deletePic(k){
	if(!confirm('是否删除？'))return;
	$(k).parent().remove();
	if($('#imgs').children().length<6)$('#file').show();
}
function deleteSelf(k){
	$(k).parent().parent().remove();
}
function setDragsort(){
	$('#imgs').dragsort({
		dragList : 'div',
		dragItem : 'span',
		//lockRange : true,
		placeHolder : '<div class="hold"></div>',
		start : function(){
			$('.hold').html(this.html()).attr('style', this.attr('data-style')).css({
				width:this.outerWidth(false),
				height:this.outerHeight(false),
				opacity:0.3
			});
		}
	});
}
$(function(){
	setDragsort();
	$('#begin_time').datepicker();
	$('#end_time').datepicker();
	//添加图片
	$('#files').html5upload({
		url : '?app=goods&act=upload_pic',
		name : 'pic',
		dataType : 'text',
		before : function(){
			if($('#imgs').children().length>=6){
				alert('图片不可超过6张');
				return false;
			}
			$.overload();
		},
		success : function(url){
			$.overload(false);
			var html = '<div>\
				<span title="拖动改变顺序">≡</span>\
				<a href="'+url+'" target="_blank" style="background-image:url('+url+');"></a>\
				<input type="hidden" name="pics[]" value="'+url+'" />\
				<input type="text" name="memos[]" placeholder="图片说明" value="" />\
				<input type="text" name="videos[]" placeholder="视频网址" value="" />\
				<a href="javascript:void(0)" onclick="deletePic(this)"></a>\
			</div>';
			$('#imgs').append(html);
			if($('#imgs').children().length>=6)$('#file').hide();
			setDragsort();
		}
	});
	//添加规格
	$('#add').click(function(){
		var html = '<tr align="center">\
			<td><input type="text" name="spec[]" /></td>\
			<td><input type="text" name="sto[]" /></td>\
			<td><input type="text" name="pri[]" /></td>\
			<td><input type="text" name="pro[]" /></td>\
			<td><a href="javascript:void(0)" onclick="deleteSelf(this)">删除</a></td>\
		</tr>';
		$('#addTr').append(html);
	});
	$('#stocks').on('keyup blur', function(){
		$('#sto0').val($(this).val());
	});
	$('#price').on('keyup blur', function(){
		$('#pri0').val($(this).val());
	});
	$('#promote_price').on('keyup blur', function(){
		$('#pro0').val($(this).val());
	});
	$('#sto0').on('keyup blur', function(){
		$('#stocks').val($(this).val());
	});
	$('#pri0').on('keyup blur', function(){
		$('#price').val($(this).val());
	});
	$('#pro0').on('keyup blur', function(){
		$('#promote_price').val($(this).val());
	});
	$('#free1').click(function(){
		$('.cost').hide();
	});
	$('#free2').click(function(){
		$('.cost').show();
	});
});
</script>